{% extends "fmbase.html" %}

{% load i18n %}

{% block title %}{{ pwd }} &ndash; {{ block.super }}{% endblock %}

{% block js %}
    <script>
    var pwd = "{{ pwd }}";
    var url_media = "{{ fileman_media_url }}";
    var url_preview = "{% url fileman.views.preview %}";
    var url_geturl = "{% url fileman.views.getUrl %}";
    var url_home = "{% url fileman.views.ls %}";
    var url_view = "{% url fileman.views.view %}";
    var url_delete = "{% url fileman.views.delete2 %}";
    var url_destraction = "{% url fileman.views.destraction2 %}";
    var url_createdir = "{% url fileman.views.createDir %}";
    var url_addbufer = "{% url fileman.views.addBuffer %}";
    var url_removebuffer = "{% url fileman.views.RemoveFromBuffer %}";
    </script>
    <script type="text/javascript" src="{{ fileman_media_url }}/script.js"></script>
{% endblock %}

{% block sidebar %}
    <div class="block actions">
    <h2>{% trans "Actions" %}</h2>
        <div class="content">
        <p><img src="{{ fileman_media_url }}/user.gif"> {{ user }}
        {% if not anonymous %}<a href="#">[ {% trans "Exit" %} ]</a>{% endif %}</p><br>
        <p><a href="{% url fileman.views.ls %}"><img src="{{ fileman_media_url }}/house.png"> {% trans "Home directory" %}</a></p>
        {% if perms.fileman.can_fm_add %}<p><a href="#" onclick="return createDir();"><img src="{{ fileman_media_url }}/folder_add.png"> {% trans "Create directory" %}</a></p>{% endif %}
        {% if perms.fileman.can_fm_add %}<p><a href="{% url fileman.views.past %}{{ pwd }}"><img src="{{ fileman_media_url }}/page_white_paste.png"> {% trans "Past" %}</a></p>{% endif %}
        {% if perms.fileman.can_fm_del %}<p><a href="{% url fileman.views.listBasket %}"><img src="{{ fileman_media_url }}/bin.png"> {% trans "Recycle Bin" %}</a></p>{% endif %}
        <br>
        {% if perms.fileman.can_fm_del %}<p><a href="#" onclick="return del();"><img src="{{ fileman_media_url }}/delete.png"> {% trans "Delete" %}</a></p>{% endif %}
        {% if perms.fileman.can_fm_destruct %}<p><a href="#" onclick="return dest();"><img src="{{ fileman_media_url }}/cross.png"> {% trans "Destroy" %}</a></p>{% endif %}
        </div>
    </div>
    <div class="block buffer">
    <h2>{% trans "Buffer" %}</h2>
        <div class="content">
        {% if  buffer %}
        {% for file, action, name in buffer %}
            <div>{% ifequal action 1 %}<img src="{{ fileman_media_url }}/page_white_copy.png">{% endifequal %}
            {% ifequal action 2 %}<img src="{{ fileman_media_url }}/cut.png">{% endifequal %}
            {{ name }}
            <a href="#" onclick="return RemoveFromBuffer(this, '{{ file }}');"><img src="{{ fileman_media_url }}/cross.png"></a>
            </div>
        {% endfor %}
        {% else %}
        <div id="clearBuffer">
            Буфер пуст.
        </div>
        {% endif %}
        </div>
    </div>
    <div class="block info">
    <h2>{% trans "Info" %}</h2>
        <div class="content">
        <p>{% trans "Link" %}: <input id="url" type="input"></p>
        <p><a href="#" id="clipboard">{% trans "copy to clipboard" %}</a></p>
        <p id="download"><a href="#">{% trans "download" %}</a></p>
        </div>
    </div>
    {% if perms.fileman.can_fm_add %}
    <div class="block upload">
    <h2>{% trans "Upload" %}</h2>
        <div class="content">
        <form id="uploadForm" action="{% url fileman.views.upload %}" method="post" enctype="multipart/form-data">
        <p><input type="file" name="ufile1" size="10"></p>
        <p id="addFileFild"><a href="#" onclick="return addFileFild();">{% trans "add" %}</a></p>
        <p><input type="hidden" name="path" value="{{ pwd }}">
        <input type="submit" value="{% trans 'Upload!' %}"></p>
        </form>
        </div>
    </div>
    {% endif %}
    <div class="block preview">
    <h2>{% trans "Preview" %}</h2>
        <div class="content">
        <p>
        {% trans "No picture" %}
        </p>
        </div>
    </div>
{% endblock %}

{% block main %}
    {% if perms.fileman.can_fm_list %}
    <div id="pwd"><b>{% trans "You are here:" %}</b> {{ pwd }}</div>
    <form id="fileListForm" method="post">
    <table id="filelist" cellpadding="0" cellspacing="0">
    {% ifnotequal pwd user.fileman_Setting.root %}
    <tr>
    <td><input DISABLED type="checkbox" id="d">
    <img src="{{ fileman_media_url }}/bullet_go.png"> <label for="d" class="dir">..</label></td>
    <td>&nbsp;</td>
    {% if perms.fileman.can_fm_add %}
    <td>&nbsp;</td>
    {% endif %}
    {% if perms.fileman.can_fm_rename %}
    <td>&nbsp;</td>
    {% endif %}
    {% if perms.fileman.can_fm_rename %}
    <td>&nbsp;</td>
    {% endif %}
    {% if perms.fileman.can_fm_del %}
    <td>&nbsp;</td>
    {% endif %}
    {% if perms.fileman.can_fm_destruct %}
    <td>&nbsp;</td>
    {% endif %}
    </tr>
    {% endifnotequal %}
    {% include "dirs.html" %}
    {% include "files.html" %}
    </form>
    </table>

    {% endif %}
{% endblock %}
